// 引入api
import { reqAddressInfo, reqOrderInfo } from '@/api/index'

// trade页面的仓库
const state = {
    addressInfo: [],
    orderInfo: {}
};
const actions = {
    // 获取用户地址信息
    async getUserAddress({ commit }) {
        let res = await reqAddressInfo();
        if (res.code == 200) {
            console.log('地址信息获取成功');
            commit('GETUSERADDRESS', res.data);
        } else {
            console.log('地址信息获取失败,' + res.message);
        }
    },
    // 获取商品清单的数
    async getOrderInfo({ commit }) {
        let res = await reqOrderInfo();
        if (res.code == 200) {
            console.log('获取订单信息成功');
            commit('GETORDERINFO', res.data);
        } else {
            console.log('订单信息获取失败,' + res.message);
        }
    }
};
const mutations = {
    GETUSERADDRESS(state, addressInfo) {
        state.addressInfo = addressInfo;
    },
    GETORDERINFO(state, orderInfo) {
        state.orderInfo = orderInfo;
    }
};
const getters = {};

export default {
    state,
    actions,
    mutations,
    getters,
}